{extend name="index/iframe" /}

{block name="content"}
<form class="layui-form layui-form-my" action="">
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">公告类型</label>
        <div class="layui-input-block select-box">
            <select name="notice_type" lay-filter="notice_type" id="notice_type" lay-verify="required">
                <option value="">公告类型（全部）</option>
                {foreach $Think.config.notice_type as $k=>$v}
                <option value="{$k}">{$v}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公告标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">公告等级</label>
        <div class="layui-input-block">
            {foreach $Think.config.notice_grade as $k=>$v}
            <input type="radio" name="notice_grade" value="{$k}" title="{$v}" {$k==1 ? 'checked' : ''}>
            {/foreach}
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">发布人</label>
        <div class="layui-input-block">
            <input type="text" value="米娱游戏" name="author" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">发布时间</label>
        <div class="layui-input-block">
            <input type="text" name="release_time" class="layui-input" lay-verify="required|datetime" id="datetime" placeholder="yyyy-MM-dd HH:mm:ss"  lay-verify="datetime" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block" style="width: 1000px;">
            {MyTag:umditor name="content" content="" height="400px" /}
        </div>
    </div>
    <div class="layui-form-item" style="margin-bottom: 100px;">
        <div class="layui-input-block">
            <button class="layui-btn my-btn" lay-submit="" lay-filter="submitBtn">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}

{block name="css"}
{/block}

{block name="js"}
<script>
    layui.use(['form', 'layedit', 'laydate', 'upload', 'element'], function(){
        var form = layui.form
            ,$ = layui.$
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,layedit = layui.layedit;


        //日期
        laydate.render({
            elem: '#datetime'
            ,type: 'datetime'
            ,value: new Date()
        });

        //提交
        form.on('submit(submitBtn)', function(data){
            var load = layer.load();
            $.post('{:url("ChannelNotice/add")}',data.field, function(json){
                layer.close(load);
                json.code==0 ? layer.msg(json.msg, {icon: 1, time: 1000}) : layer.msg(json.msg, {icon: 0, time: 1000});
            }, 'JSON').error(function(){
                layer.close(load);
                layer.msg('连接超时，请联系后台管理员', {icon: 2, time:3000});
            });
            return false;
        });
    });
</script>
{/block}